capture log close
clear
set more off
set matsize 5000

# delimit ;


/*
DATA SOURCES:
Dealscan
Compustat
CRSP
FISD
Y9C/Call reports
Salomon Brothers/Citigroup bond indices
Treasury indices
*/

 
gen lquarter=quarter(facility_start_date);
gen lyear=year(facility_start_date);
egen lyq=group(lyear lquarter);
egen bk_firm=group(topid company_id_sub);
egen bk_lyear=group(topid lyear);

drop if lyear<1986;
drop if lyear>2016;

gen bef_basel1=(lyear<1993);
gen basel12a=(lyear>1992 & lyear<2005);
gen post_basel2=(lyear>2004);

/* BORROWER */
destring lpc_sic, replace;
replace lpc_sic=0 if lpc_sic==.;
gen sic1=(lpc_sic>0 & lpc_sic<1500);
gen sic2=(1500<lpc_sic & lpc_sic<2000);
gen sic3=(2000<lpc_sic & lpc_sic<4000);
gen sic4=(4000<lpc_sic & lpc_sic<5000);
gen sic5=(5000<lpc_sic & lpc_sic<6000);
gen sic6=(6000<lpc_sic & lpc_sic<7000);
gen sic7=(7000<lpc_sic & lpc_sic<9000);
/* Dropping financials */
drop if sic6==1;

gen aaa=(data280-2==0);
gen aa=(data280>3 & data280<7);
gen a=(data280>6 & data280<10);
gen bbb=(data280>9 & data280<13);
gen bb=(data280>12 & data280<16);
gen b=(data280>15 & data280<19);
gen ccc=(data280>18 & data280<22);
gen cc=(data280>21 & data280<25);
gen default=(data280>26 & data280<30);
gen cc_def=cc+default;

gen Lfsales=ln(data12);
gen leverage=(data9+data34)/data6;
gen mkttobook=(data6-data60+data25*data199)/data6;
gen profitmg=data172/(data12+1);
gen tangibles=(data3+data7)/data6;
replace data46=0 if data46==.;
gen rd=data46/(data12+1);
replace data45=0 if data45==.;
gen advert=data45/(data12+1);
gen nwc=(data4-data5)/(data9+data34+1);
gen data15d=(data15>0);
gen intcov=data15d*(data13/data15)+(1-data15d)*data13;
gen intcovd=intcov>0;
gen Lintcov=ln(1+intcov*intcovd);

foreach var of varlist 
leverage mkttobook profitmg nwc tangibles rd advert ex_ret volatility
{;
winsor `var', gen(`var'W) p(0.01);
};

/* LOAN */

gen term_loan=( loan_type=="Delay Draw Term Loan" | loan_type=="Term Loan" | loan_type=="Term Loan A" | 
	loan_type=="Term Loan B" | loan_type=="Term Loan C" | loan_type=="Term Loan D" | loan_type=="Term Loan E" |
	loan_type=="Term Loan F" | loan_type=="Term Loan G" | loan_type=="Term Loan H" | loan_type=="Bridge Loan" | loan_type=="Other Loan");
gen credit_line=( loan_type=="Revolver/Line < 1 Yr." 	| loan_type=="Revolver/Line >= 1 Yr." | loan_type=="364-Day Facility" | loan_type=="Revolver/Term Loan" );
gen credit_line365=( loan_type=="364-Day Facility");

drop if credit_line==0 & term_loan==0;

drop if facility_amount==.;
gen amount=(facility_amount/1000000);
gen Lamount=ln(amount);

gen maturity_cat=int((lpc_mon_to_maturity-1)/12)+1;
replace maturity_cat=10 if maturity_cat>10;
gen maturity=(lpc_mon_to_maturity/12);

gen clmaturity_sm12a=(lpc_mon_to_maturity<12)*credit_line;
gen clmaturity_sm12=(lpc_mon_to_maturity<=12)*credit_line;
gen clmaturity_1224=(lpc_mon_to_maturity>12 & lpc_mon_to_maturity<=24)*credit_line;
gen tlmaturity_sm12=(lpc_mon_to_maturity<=12)*term_loan;

gen grantord=0 if  guarantor=="";
replace grantord=1 if guarantor!="";
gen sponsord= 0 if sponsor_original=="";
replace sponsord=1 if sponsor_origina!="";
gen renewald=(renewal=="Yes");
gen refinanced=(refinancing_indicator=="Yes");
gen securedd=(secured=="Yes");
gen unsecured=(secured=="No");
gen secured_mis=(securedd==0 & unsecured==0);
gen seniord=(seniority=="Senior");
gen divident_rest=(divident_restrictions=="Yes");
gen corp_pur=(deal_purpose=="Corp. purposes");
gen debt_rep=(deal_purpose=="Debt Repay.");
gen work_cap=(deal_purpose=="Work. cap.");
gen cp_bkup=(deal_purpose=="CP backup");
gen MergAcq=(deal_purpose=="LBO" | deal_purpose=="Merger" | deal_purpose=="Takeover" );

drop if all_in_drawn==.;
foreach var of varlist 
all_in_undrawn all_in_drawn 
{;
winsor `var', gen(`var'W) p(0.01);
};

/* MARKET */

gen bbb_spdcomb=ml_md_baa-ml_md_aaa;
gen teny_slope=tenyear-threemonth;
gen st_teny_slope=clmaturity_sm12*teny_slope;


/* BANK */

gen Lqassets=ln(qassets/1000000);
gen qsubdebt_rat=qsubdebt/qassets;
gen qbkroa=qnetinc/qassets;
replace  qnetxoff_tot=0 if  qnetxoff_tot==.;
gen qnetxoff_asset=qnetxoff_tot/qassets;
gen qliquidity_rat=(qcash+qinv_sec)/qassets;
gen qequity_rat=(qequity/qassets);

foreach var of varlist 
qsubdebt_rat qbkroa qnetxoff_asset qliquidity_rat qequity_rat sdroa_lender
{;
winsor `var', gen(`var'W) p(0.01);
};

global LOAN
Lamount renewald securedd secured_mis divident_rest grantord sponsord corp_pur debt_rep work_cap cp_bkup MergAcq; 

global SYNDICATE
num_lenders;

global BANK
Lqassets qsubdebt_ratW qbkroaW qnetxoff_assetW qliquidity_ratW qequity_ratW sdroa_lenderW;

global FIRM
Lfsales leverageW mkttobookW profitmgW nwcW Lintcov tangiblesW rdW advertW ex_retW volatilityW sic1 sic2 sic3 sic4 sic5 sic7;

global FIRMRAT
aaa aa a bbb bb b ccc cc_def;

global MARKET
bbb_spdcomb;

gen stlibor=clmaturity_sm12*libor3m;
gen stBBB=clmaturity_sm12*bbb_spdcomb ;


foreach var of varlist 
aaa aa a bbb bb b ccc cc_def 
Lfsales leverageW mkttobookW profitmgW nwcW Lintcov tangiblesW rdW advertW ex_retW volatilityW
sic1 sic2 sic3 sic4 sic5 sic7
Lqassets qsubdebt_ratW qbkroaW qnetxoff_assetW qliquidity_ratW qequity_ratW sdroa_lenderW
Lamount  renewald securedd secured_mis  divident_rest grantord sponsord corp_pur debt_rep work_cap cp_bkup MergAcq
num_lenders bbb_spdcomb stBBB teny_slope st_teny_slope
{;
gen basel12a_`var'=basel12a*`var';
};

global basel12a_LOAN
basel12a_Lamount  basel12a_renewald basel12a_securedd basel12a_secured_mis  basel12a_divident_rest basel12a_grantord basel12a_sponsord basel12a_corp_pur basel12a_debt_rep basel12a_work_cap basel12a_cp_bkup basel12a_MergAcq  ; 

global basel12a_SYNDICATE
basel12a_num_lenders;

global basel12a_BANK
basel12a_Lqassets basel12a_qsubdebt_ratW basel12a_qbkroaW basel12a_qnetxoff_assetW basel12a_qliquidity_ratW basel12a_qequity_ratW basel12a_sdroa_lenderW;

global basel12a_FIRM
basel12a_Lfsales basel12a_leverageW basel12a_mkttobookW basel12a_profitmgW basel12a_nwcW basel12a_Lintcov basel12a_tangiblesW basel12a_rdW basel12a_advertW basel12a_ex_retW basel12a_volatilityW
basel12a_sic1 basel12a_sic2 basel12a_sic3 basel12a_sic4 basel12a_sic5 basel12a_sic7;

global basel12a_FIRMRAT
basel12a_aaa basel12a_aa basel12a_a basel12a_bbb basel12a_bb basel12a_b basel12a_ccc basel12a_cc_def;

global basel12a_MARKET
basel12a_bbb_spdcomb;
 
foreach var of varlist 
aaa aa a bbb bb b ccc cc_def 
Lfsales leverageW mkttobookW profitmgW nwcW Lintcov tangiblesW rdW advertW ex_retW volatilityW
sic1 sic2 sic3 sic4 sic5 sic7
Lqassets qsubdebt_ratW qbkroaW qnetxoff_assetW qliquidity_ratW qequity_ratW sdroa_lenderW
Lamount  renewald securedd secured_mis  divident_rest grantord sponsord corp_pur debt_rep work_cap cp_bkup MergAcq
num_lenders bbb_spdcomb stBBB teny_slope
{;
gen pbasel2_`var'=post_basel2*`var';
};
 
global pbasel2_LOAN
pbasel2_Lamount  pbasel2_renewald pbasel2_securedd pbasel2_secured_mis pbasel2_divident_rest pbasel2_grantord pbasel2_sponsord pbasel2_corp_pur pbasel2_debt_rep pbasel2_work_cap pbasel2_cp_bkup pbasel2_MergAcq  ; 

global pbasel2_SYNDICATE
pbasel2_num_lenders;

global pbasel2_BANK
pbasel2_Lqassets pbasel2_qsubdebt_ratW pbasel2_qbkroaW pbasel2_qnetxoff_assetW pbasel2_qliquidity_ratW pbasel2_qequity_ratW pbasel2_sdroa_lenderW;

global pbasel2_FIRM
pbasel2_Lfsales pbasel2_leverageW pbasel2_mkttobookW pbasel2_profitmgW pbasel2_nwcW pbasel2_Lintcov pbasel2_tangiblesW pbasel2_rdW pbasel2_advertW pbasel2_ex_retW pbasel2_volatilityW
pbasel2_sic1 pbasel2_sic2 pbasel2_sic3 pbasel2_sic4 pbasel2_sic5 pbasel2_sic7;

global pbasel2_FIRMRAT
pbasel2_aaa pbasel2_aa pbasel2_a pbasel2_bbb pbasel2_bb pbasel2_b pbasel2_ccc pbasel2_cc_def;

global pbasel2_MARKET
pbasel2_bbb_spdcomb;

gen basel12a_sm12=basel12a*clmaturity_sm12;
gen pbasel2_sm12=post_basel2*clmaturity_sm12;
gen basel12a_sm24=basel12a*clmaturity_1224;

gen credit_line365_exp=credit_line365*(1-bef_basel1)+clmaturity_sm12*bef_basel1;
gen basel12a_cl365_exp= basel12a*credit_line365_exp;
gen credit_line365_expa=credit_line365*(1-post_basel2)+clmaturity_sm12*post_basel2;
gen pbasel2_cl365_expa= post_basel2*credit_line365_expa;

gen basel12a_cl365= basel12a*credit_line365;
gen pbasel2_cl365= post_basel2*credit_line365;
gen basel12a_tlsm12=basel12a*tlmaturity_sm12;
gen pbasel2_tlsm12=post_basel2*tlmaturity_sm12;

/* low is below the first quartile */
quietly
reg all_in_drawnW basel12a  $LOAN $SYNDICATE  $FIRMRAT $MARKET $FIRM
if  credit_line==1 & lyear>1986 & lyear<2004, robust cluster(company_id_sub) ; 
_pctile qequity_ratW if e(sample)==1, percentiles(25 50 75);
gen eq25 = (qequity_ratW <= r(r1))*r(r1);
gen eq50 = (qequity_ratW <= r(r2))*r(r2);
gen eq75 = (qequity_ratW <= r(r4))*r(r4);
gen low_cap=(qequity_ratW<.0611);

gen basel12a_low_cap= basel12a*low_cap;
gen clmaturity_sm12_low_cap=clmaturity_sm12*low_cap;
gen basel12a_sm12_low_cap=basel12a*clmaturity_sm12*low_cap;

foreach var of varlist 
aaa aa a bbb bb b ccc cc_def 
Lfsales leverageW mkttobookW profitmgW nwcW Lintcov tangiblesW rdW advertW ex_retW volatilityW
sic1 sic2 sic3 sic4 sic5 sic7
Lqassets qsubdebt_ratW qbkroaW qnetxoff_assetW qliquidity_ratW qequity_ratW sdroa_lenderW
Lamount  renewald securedd secured_mis  divident_rest grantord sponsord corp_pur debt_rep work_cap cp_bkup MergAcq
num_lenders bbb_spdcomb
{;
gen low_`var'=low_cap*`var';
gen low_basel2_`var'=low_cap*basel12a*`var';
};


global low_LOAN
low_Lamount  low_renewald low_securedd low_secured_mis  low_divident_rest low_grantord low_sponsord low_corp_pur low_debt_rep low_work_cap low_cp_bkup low_MergAcq  ; 

global low_SYNDICATE
low_num_lenders;

global low_BANK
low_Lqassets low_qsubdebt_ratW low_qbkroaW low_qnetxoff_assetW low_qliquidity_ratW low_qequity_ratW low_sdroa_lenderW;

global low_FIRM
low_Lfsales low_leverageW low_mkttobookW low_profitmgW low_nwcW low_Lintcov low_tangiblesW low_rdW low_advertW low_ex_retW low_volatilityW
low_sic1 low_sic2 low_sic3 low_sic4 low_sic5 low_sic7;

global low_FIRMRAT
low_aaa low_aa low_a low_bbb low_bb low_b low_ccc low_cc_def;

global low_MARKET
low_bbb_spdcomb;

global low_basel12a_LOAN
low_basel2_Lamount  low_basel2_renewald low_basel2_securedd low_basel2_secured_mis  low_basel2_divident_rest low_basel2_grantord low_basel2_sponsord low_basel2_corp_pur low_basel2_debt_rep low_basel2_work_cap low_basel2_cp_bkup low_basel2_MergAcq  ; 

global low_basel12a_SYNDICATE
low_num_lenders;

global low_basel12a_BANK
low_basel2_Lqassets low_basel2_qsubdebt_ratW low_basel2_qbkroaW low_basel2_qnetxoff_assetW low_basel2_qliquidity_ratW low_basel2_qequity_ratW low_basel2_sdroa_lenderW;

global low_basel12a_FIRM
low_basel2_Lfsales low_basel2_leverageW low_basel2_mkttobookW low_basel2_profitmgW low_basel2_nwcW low_basel2_Lintcov low_basel2_tangiblesW low_basel2_rdWlow_basel2_advertW low_basel2_ex_retW low_basel2_volatilityW
low_basel2_sic1 low_basel2_sic2 low_basel2_sic3 low_basel2_sic4 low_basel2_sic5 low_basel2_sic7;

global low_basel12a_FIRMRAT
low_basel2_aaa low_basel2_aa low_basel2_a low_basel2_bbb low_basel2_bb low_basel2_b low_basel2_ccc low_basel2_cc_def;

global low_basel12a_MARKET
low_basel2_bbb_spdcomb;

reghdfe, compile;


/* Table 3 */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1986 & lyear<2004, fcluster(lyq) tcluster(company_id_sub);	 	 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1986 & lyear<2004, fcluster(lyq) tcluster(company_id_sub);	 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1986 & lyear<2004, a(topid) vce(cluster company_id_sub lyq);

estout T1_a T1_b T1_c using RFS_TABLE_3.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
Lqassets LASSETSbk qsubdebt_ratW SUBDEBTbk qbkroaW ROAbk qnetxoff_assetW CHARGEOFFSbk qliquidity_ratW LIQUIDITYbk qequity_ratW CAPITALbk sdroa_lenderW ROAVOLbk
Lfsales LSALES leverageW LEVERAGE mkttobookW MKTBOOK profitmgW PROFMARGIN nwcW NWC Lintcov LINTCOV tangiblesW TANGIBLES rdW R\&D advertW ADVERTISING ex_retW STOCKRET volatilityW STOCKVOL aaa AAA aa AA a A bbb BBB bb BB b B ccc CCC cc_def CC
Lamount LAMOUNT renewald RENEWAL securedd SECURED secured_mis SECUREDMIS divident_rest DIVIDEND grantord GUARANTOR sponsord SPONSOR corp_pur CORPURPOSES debt_rep DEBTREPAY work_cap WORKCAPITAL cp_bkup CPBCKUP MergAcq M\A 
num_lenders LENDERS bbb_spdcomb BBBSPREAD
basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons 
Lqassets qsubdebt_ratW qbkroaW qnetxoff_assetW qliquidity_ratW qequity_ratW sdroa_lenderW 
Lfsales leverageW mkttobookW profitmgW nwcW Lintcov tangiblesW rdW advertW ex_retW volatilityW
aaa aa a bbb bb b ccc cc_def
Lamount  renewald securedd secured_mis  divident_rest grantord sponsord corp_pur debt_rep work_cap cp_bkup MergAcq 
num_lenders bbb_spdcomb
basel12a clmaturity_sm12 basel12a_sm12
)
style(tex)
replace;


/* Table 4a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);	 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);	 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c  using RFS_TABLE_4a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a  clmaturity_sm12 basel12a_sm12
)
style(tex)
replace;


/* Table 4b */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12   
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, a(topid) vce(cluster topid lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_4b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
)               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 basel12a_sm12  
)
style(tex)
replace;

/* Table 5a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12  
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, a(topid) vce(cluster topid lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_5a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
basel12a_low_cap BASEL1{\times}LOWCAP  clmaturity_sm12_low_cap LOWCAP{\times}ST low_cap LOWCAP basel12a_sm12_low_cap BASEL1{\times}LOWCAP{\times}ST
)               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_sm12 basel12a_sm12 basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap 
)
style(tex)
replace;

/* Table 5b */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a  clmaturity_sm12 basel12a_sm12  
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1986 & lyear<2004 & maturity_cat<4, a(topid) vce(cluster topid lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_5b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
basel12a_low_cap BASEL1{\times}LOWCAP  clmaturity_sm12_low_cap LOWCAP{\times}ST low_cap LOWCAP basel12a_sm12_low_cap BASEL1{\times}LOWCAP{\times}ST
)               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 basel12a_sm12 basel12a_low_cap clmaturity_sm12_low_cap basel12a_sm12_low_cap low_cap 
)
style(tex)
replace;

/* Table 6a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);	

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);	

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_6a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a  clmaturity_sm12 basel12a_sm12
)
style(tex)
replace;

/* Table 6b */
preserve;
drop if clmaturity_sm12==1 & clmaturity_sm12a==0;
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_6b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_sm12 basel12a_sm12 
)
style(tex)
replace;
restore;

/* Table 6c */
preserve;
drop if credit_line365==0 & maturity_cat==1 & bef_basel1==0;
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if  credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_6c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 credit_line365_exp 364FAC basel12a_cl365_exp BASEL1{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a credit_line365_exp basel12a_cl365_exp  
)
style(tex)
replace;
restore;


/* Tabke 7a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_1224 basel12a_sm24  
$LOAN $SYNDICATE $BANK $FIRMRAT  $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<5 & clmaturity_sm12==0, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
basel12a clmaturity_1224 basel12a_sm24   
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<5 & clmaturity_sm12==0, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
basel12a clmaturity_1224 basel12a_sm24    
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1988 & lyear<1995 & maturity_cat<5 & clmaturity_sm12==0, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_7a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_1224 ST2y basel12a_sm24 BASEL1{\times}ST2y
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_1224 basel12a_sm24  
)
style(tex)
replace;

/* Tabke 7b */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_drawnW
basel12a clmaturity_sm12 basel12a_sm12 stBBB teny_slope st_teny_slope 
$LOAN $SYNDICATE $BANK $FIRMRAT  $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_b:
quietly	
xi: cluster2 all_in_drawnW
basel12a clmaturity_sm12 basel12a_sm12 stBBB teny_slope st_teny_slope
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_c:
quietly	
xi: reghdfe all_in_drawnW
basel12a clmaturity_sm12 basel12a_sm12 stBBB teny_slope st_teny_slope
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_7b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_sm12 basel12a_sm12
)
style(tex)
replace;

/* Table 7c */
quietly	
xi: reg all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12  
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if  credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, robust cluster(company_id_sub); 
gen basel1_sample=1 if e(sample)==1;
spread basel1_sample, by(package_id); 

quietly	
xi: reg all_in_undrawnW
basel12a clmaturity_sm12 basel12a_sm12  
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, robust cluster(company_id_sub); 
gen basel1_sampleF=1 if e(sample)==1;
spread basel1_sampleF, by(package_id); 

eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_drawnW
basel12a tlmaturity_sm12 basel12a_tlsm12 stBBB teny_slope st_teny_slope 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if term_loan==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & basel1_sample!=1, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_b:
quietly	
xi: cluster2 all_in_drawnW
basel12a tlmaturity_sm12 basel12a_tlsm12 stBBB teny_slope st_teny_slope
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if term_loan==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & basel1_sampleF!=1, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_c:
quietly	
xi: reghdfe all_in_drawnW
basel12a tlmaturity_sm12 basel12a_tlsm12 stBBB teny_slope st_teny_slope
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if term_loan==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & basel1_sampleF!=1, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_7c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 tlmaturity_sm12 STtl basel12a_tlsm12 BASEL1{\times}STtl
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a tlmaturity_sm12 basel12a_tlsm12
)
style(tex)
replace;


/* Table 8a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT  $MARKET
if credit_line==1 & lyear>1999 & lyear<2008, fcluster(lyq) tcluster(company_id_sub);

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1999 & lyear<2008, fcluster(lyq) tcluster(company_id_sub);

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1999 & lyear<2008, a(topid) vce(cluster company_id_sub lyq);

estout T1_a T1_b T1_c using RFS_TABLE_8a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant post_basel2 BASEL2 clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons 
post_basel2 clmaturity_sm12 pbasel2_sm12
)
style(tex)
replace;

/* Table 8b */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_8b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant post_basel2 BASEL2 clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons post_basel2 clmaturity_sm12 pbasel2_sm12
)
style(tex)
replace;

/* Table 8c */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $pbasel2_LOAN $pbasel2_SYNDICATE $pbasel2_BANK $pbasel2_FIRMRAT $pbasel2_MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $pbasel2_LOAN $pbasel2_SYNDICATE $pbasel2_BANK $pbasel2_FIRMRAT $pbasel2_FIRM $pbasel2_MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $pbasel2_LOAN $pbasel2_SYNDICATE $pbasel2_BANK $pbasel2_FIRMRAT $pbasel2_FIRM $pbasel2_MARKET
if credit_line==1 & lyear>1999 & lyear<2008 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq);

estout T1_a T1_b T1_c using RFS_TABLE_8c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 pbasel2_sm12
)
style(tex)
replace;



/* Table IA_1a */
eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 basel12a_sm12   
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(topid); 

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster topid lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA1a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
)               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 basel12a_sm12  
)
style(tex)
replace;

/* Table IA_1b */
preserve;
drop if  clmaturity_sm12==1 & clmaturity_sm12a==0;

eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA1b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 basel12a_sm12 
)
style(tex)
replace;
restore;

/* Table IA_1c */
preserve;
drop if credit_line365==0 & maturity_cat==1 & bef_basel1==0;

eststo clear;
eststo T1_a:
quietly	
xi: cluster2 all_in_undrawnW
credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_b:
quietly	
xi: cluster2 all_in_undrawnW
credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, fcluster(lyq) tcluster(company_id_sub);

eststo T1_c:
quietly	
xi: reghdfe all_in_undrawnW
credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET $basel12a_LOAN $basel12a_SYNDICATE $basel12a_BANK $basel12a_FIRMRAT $basel12a_FIRM $basel12a_MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA1c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant credit_line365_exp 364FAC basel12a_cl365_exp BASEL1{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons credit_line365_exp basel12a_cl365_exp  
)
style(tex)
replace;
restore;

/* Table IA_2a */
gen control_clmaturity_sm12=1 if clmaturity_sm12==1 & clmaturity_sm12a==0 ;
gen control_cl365_exp=1 if credit_line365==0 & maturity_cat==1 & bef_basel1==0 ;
gen control_cl365=1 if credit_line365==0 & maturity_cat==1 ;

eststo clear;
eststo T1_a:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(bk_lyear) vce(cluster company_id_sub lyq);

eststo T1_b:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a  clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_clmaturity_sm12!=1, a(bk_lyear) vce(cluster company_id_sub lyq);

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
basel12a  credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRM $FIRMRAT $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_cl365_exp!=1, a(bk_lyear) vce(cluster company_id_sub lyq);

estout T1_a T1_b T1_c using RFS_TABLE_IA2a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST
credit_line365_exp 364FAC basel12a_cl365_exp BASEL1{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons 
  clmaturity_sm12 basel12a_sm12 credit_line365_exp basel12a_cl365_exp 
)
style(tex)
replace;

/* Table IA2_b */
eststo clear;
eststo T1_a:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a  clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(topid company_id_sub) vce(cluster company_id_sub lyq); 

eststo T1_b:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a  clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_clmaturity_sm12!=1, a(topid company_id_sub) vce(cluster company_id_sub lyq); 

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
basel12a  credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_cl365_exp!=1, a(topid company_id_sub) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA2b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
credit_line365_exp 364FAC basel12a_cl365_exp BASEL1{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_sm12 basel12a_sm12 credit_line365_exp basel12a_cl365_exp 
)
style(tex)
replace;

/* Table IA2_c */
eststo clear;
eststo T1_a:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4, a(bk_firm) vce(cluster company_id_sub lyq); 

eststo T1_b:
quietly	
xi: reghdfe all_in_undrawnW 
basel12a clmaturity_sm12 basel12a_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_clmaturity_sm12!=1, a(bk_firm) vce(cluster company_id_sub lyq); 

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
basel12a credit_line365_exp basel12a_cl365_exp 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>1989 & lyear<1996 & maturity_cat<4 & control_cl365_exp!=1, a(bk_firm) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA2c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
basel12a BASEL1 clmaturity_sm12 ST basel12a_sm12 BASEL1{\times}ST 
credit_line365_exp 364FAC basel12a_cl365_exp BASEL1{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons basel12a clmaturity_sm12 basel12a_sm12 credit_line365_exp basel12a_cl365_exp 
)
style(tex)
replace;

/* Table IA3_a */

gen basel2_control1=1 if clmaturity_sm12==1 & clmaturity_sm12a==0;
gen basel2_control2=1 if credit_line365==0 & maturity_cat==1 & post_basel2==0;

eststo clear;
eststo T1_a:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4, a(bk_lyear) vce(cluster company_id_sub lyq);

eststo T1_b:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control1!=1, a(bk_lyear) vce(cluster company_id_sub lyq); 

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
post_basel2  credit_line365_expa pbasel2_cl365_expa 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control2!=1, a(bk_lyear) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA3a.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
post_basel2 BASEL2 clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
credit_line365_expa 364FAC pbasel2_cl365_expa BASEL2{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons clmaturity_sm12 pbasel2_sm12 credit_line365_expa pbasel2_cl365_expa  
)
style(tex)
replace;

/* Table IA3_b */
eststo clear;
eststo T1_a:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4, a(topid company_id_sub) vce(cluster company_id_sub lyq);

eststo T1_b:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control1!=1, a(topid company_id_sub) vce(cluster company_id_sub lyq); 

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
post_basel2  credit_line365_expa pbasel2_cl365_expa 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control2!=1, a(topid company_id_sub) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA3b.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
post_basel2 BASEL2 clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
credit_line365_expa 364FAC pbasel2_cl365_expa BASEL2{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons post_basel2 clmaturity_sm12 pbasel2_sm12 credit_line365_expa pbasel2_cl365_expa  
)
style(tex)
replace;

/* Table IA3_c */
eststo clear;
eststo T1_a:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4, a(bk_firm) vce(cluster company_id_sub lyq);

eststo T1_b:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 clmaturity_sm12 pbasel2_sm12
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control1!=1, a(bk_firm) vce(cluster company_id_sub lyq); 

eststo T1_c:
quietly
xi: reghdfe all_in_undrawnW
post_basel2 credit_line365_expa pbasel2_cl365_expa 
$LOAN $SYNDICATE $BANK $FIRMRAT $FIRM $MARKET
if credit_line==1 & lyear>2001 & lyear<2008 & maturity_cat<4 & basel2_control2!=1, a(bk_firm) vce(cluster company_id_sub lyq); 

estout T1_a T1_b T1_c using RFS_TABLE_IA3c.tex, cells(b(star fmt(2)) t(par fmt(2)))  starlevels(* 0.10 ** 0.05 *** 0.01)
   varlabels(_cons constant 
post_basel2 BASEL2 clmaturity_sm12 ST pbasel2_sm12 BASEL2{\times}ST
credit_line365_expa 364FAC pbasel2_cl365_expa BASEL2{\times}364FAC
    )               
   stats(N r2 df_r bic, fmt(0 3 0 1) label(Observations R-squared dfres BIC))
	keep(_cons post_basel2 clmaturity_sm12 pbasel2_sm12 credit_line365_expa pbasel2_cl365_expa  
)
style(tex)
replace;



stop;

